﻿using System.Collections;
using Klear.Library.Models;
using SQLite;

namespace Klear.Library.Services;

public interface IDatabaseService
{
    
    bool IsInitialized { get;}
    
    Task InitializeAsync();
    
    Task<BudgetModel> GetBudgetSettingsAsync();
    
    Task UpdateBudgetSettingsAsync(BudgetModel budgetModel);
    
    Task<decimal> GetActualSpendingAsync(DateTime startDate, DateTime endDate);

    Task<IList<IncomeAndExpensesModel>> GetIncomeAndExpensesAsync(DateTime startDate, DateTime endDate, string? title = null);

    Task<IList<IncomeAndExpensesModel>> SearchIncomeAndExpensesAsync(string title, decimal amount, string category,
        string notes, DateTime createDate);
    
    Task<IList<IncomeAndExpensesModel>> LoadIncomeAndExpensesAsync(DateTime startDate, DateTime endDate);

    Task AddRecordAsync(IncomeAndExpensesModel incomeAndExpenses);
    
    Task Delete(IncomeAndExpensesModel data);

    bool IsDatabaseInitialized();
    
    Task<IList<CategoryModel>> GetCategoriesAsync();
    
    Task<IList<CategoryModel>> GetExpenseCategoriesAsync();
    
    Task<IList<CategoryModel>> GetIncomeCategoriesAsync();
    
    Task AddCategoryAsync(CategoryModel categoryModel);
    
    Task UpdateCategoryAsync(CategoryModel categoryModel);
    
    Task DeleteCategoryAsync(CategoryModel categoryModel);
    
    event EventHandler<IncomeAndExpensesModel> ExpenseAdded;
    
    event EventHandler<IncomeAndExpensesModel> ExpenseDeleted;
    
    Task<List<BudgetModel>> GetVisualizationBudgetSettingsAsync();
    
    Task<bool> HasOverlappingBudget(DateTime startDate, DateTime endDate, int? excludeId = null);

    Task<List<BudgetModel>> GetCurrentAndFutureBudgetsAsync();

    Task DeleteBudgetAsync(BudgetModel budget);
    
    Task<BudgetModel> GetCurrentMonthBudgetAsync();
}